from django.views import generic
from django.utils import timezone

from .models import Article


# Create your views here.

class IndexView(generic.ListView):
    template_name = 'article/index.html'
    context_object_name = 'article_list'

    def get_queryset(self):
        return Article.objects.filter(createTime__lte=timezone.now()).order_by('-createTime')

class DetailView(generic.DetailView):
    model = Article
    template_name = 'article/detail.html'

    def get_queryset(self):
        return Article.objects.filter(createTime__lte=timezone.now())

class CategoryView(generic.ListView):
    template_name = 'article/category.html'
    context_object_name = 'category_list'

class TagView(generic.ListView):
    template_name = 'article/tag.html'
    context_object_name = 'tag_list'
